<?php
#####################################################
# RWCARDS - Joomla E-Cards Componment!
# Copyright (C) 2004/2005 by Ralf Weber
# Company    : LoadBrain
# Homepage   : www.weberr.de
# Version    : 2.1.0
# Date       : 23/11/2005
# License    : Released under GPL
######################################################
function com_uninstall() 
{
	global $mosConfig_absolute_path;
	
	if ( @is_dir($mosConfig_absolute_path . "/images/stories/cards") ) 
	{
    	delete_files($mosConfig_absolute_path . "/images/stories/cards", array('.', '..'));
  	}
	echo "Component successfully uninstalled.";
	return true;
}

function delete_files($target, $exceptions, $output=false) 
{
	$sourcedir = @opendir($target);
	
	while(false !== ($filename = @readdir($sourcedir))) 
	{
		if(!in_array($filename, $exceptions)) 
		{
			if($output) 
			{
				echo "Processing: ".$target."/".$filename."<br>";
			}
			if(@is_dir($target."/".$filename)) 
			{
				// recurse subdirectory; call of function recursive
				delete_files($target."/".$filename, $exceptions);
			}
			else if(@is_file($target."/".$filename)) 
			{
				// unlink file
				@unlink($target."/".$filename);
			}
		}
	}
	
	closedir($sourcedir);
	
	if(rmdir($target)) 
	{
		return true;
	}
	else
	{
		return false;
	}
}


?>